package com.study.mirrorforest.main.model.summaries.service.Impl;

import com.study.mirrorforest.main.common.response.R;
import com.study.mirrorforest.main.model.entries.dto.EntriesDTO;
import com.study.mirrorforest.main.model.entries.mapper.EntriesMapper;
import com.study.mirrorforest.main.model.summaries.dto.SummariesDTO;
import com.study.mirrorforest.main.model.summaries.dto.SummaryDTO;
import com.study.mirrorforest.main.model.summaries.mapper.SummariesMapper;
import com.study.mirrorforest.main.model.summaries.service.SummaryService;
import generator.domain.Entries;
import generator.domain.Summaries;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

@Service
public class SummaryServiceImpl implements SummaryService {

    @Autowired
    EntriesMapper entriesMapper;

    @Autowired
    SummariesMapper summariesMapper;

    @Override
    public R GetWeeklySummary(SummaryDTO summaryDTO) {
        // Implementation here
        return null;
    }

    @Override
    public R GetMonthlySummary(SummaryDTO summaryDTO) {

        return null;
    }

    @Override
    public R GetDailySummary(SummaryDTO summaryDTO) {
        Long userId = summaryDTO.getUserId();
        String date = summaryDTO.getDate();

        // 校验日期参数
        if (date == null || date.trim().isEmpty()) {
            return R.error(400, "日期参数不能为空");
        }

        List<SummariesDTO> summariesList = summariesMapper.selectByUserId(userId);
        System.out.println(summariesList);
        HashMap<String,Object> result = new HashMap<>();
        result.put("list",summariesList);
        result.put("total",summariesList.size());
        return R.ok(200, "获取每日总结成功", result);
    }

}
